const _ = require('lodash');
const loopbackContext = require('loopback-context');

module.exports = (app) => {
  app.use((req, res, callback) => {
    const user = req.user;
    if (_.isEmpty(user)) return callback();
    const context = loopbackContext.getCurrentContext();
    context.set('employeeId', user.employeeId);
    callback();
  });
};
